<%@ include file="/common/taglibs.jsp"%>
<title><fmt:message key="appRoleDetail.heading"/></title>
<script src="${ctxPath}/scripts/plugins/checktree/jquery.checktree.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="${ctxPath}/scripts/plugins/checktree/checktree.css" />
<script type="text/javascript">
	var selMenuIds=new Array();
	<c:forEach items="${appRole.appMenus}" var="rs" varStatus="i">
		selMenuIds[${i.index}]=${rs.menuId};
	</c:forEach>
	
	window.onload=function(){
			var ckMenuIds=document.getElementsByName("ckMenuId");
			for(var i=0;i<selMenuIds.length;i++){
				for(var j=0;j<ckMenuIds.length;j++){
					if(selMenuIds[i]==ckMenuIds[j].value){
						ckMenuIds[j].checked=true;
						break;
					}
				}
			}
			$j("ul.tree").checkTree({});
	}
</script>
<content tag="buttons">
	<probiz:iconBtn btnType="save" onclick="fnDoSave(this)" />
	<c:if test="${appRole.roleId!=null}">
		<probiz:iconBtn btnType="delete" onclick="fnDoDelete(this)" disabled="${(DEFAULT_ADMIN_ROLE_NAME eq appRole.roleName || appRole.isSystem == 1)?'yes':'no'}"/>
	</c:if>
	<probiz:iconBtn btnType="back" url="${ctxPath}/system/frontRole.html" />
</content>
<probiz:showBindErrors bindPath="appRole.*" />
<div class="top clearfix">
	<ul class="tab">
		<li class="curr"><span>
			<fmt:message key="appRoleDetail.heading"/>
			</span></li>
	</ul>
</div>
<div class="modify">
	<form class="mainForm" method="post" action="<c:url value="/system/frontRole.html?doAction=save"/>" id="appRole"
	onsubmit="return validateAppRole(this)">
	<input type="hidden" name="doAction" value=""/>
	<input type="hidden" name="appRoleId" value="${appRole.roleId}"/>
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="com_modi_table">
		<tr>
			<th colspan="2" class="title">
				<h4>
					<fmt:message key="appRole.group.roleInfo"/>
				</h4>
			</th>
		</tr>
		<tr>
			<th class="label_width_1">
				<StoreAdmin:label key="appRole.roleName"/>
			</th>
			<td>
				<spring:bind path="appRole.roleName">
					<c:if test="${empty appRole.roleId}">
						<input class="inputtext field200" type="text" name="${status.expression}" size="38" id="${status.expression}" value="${status.value}"/>
					</c:if>
					<c:if test="${not empty appRole.roleId }"> ${appRole.roleName}
						<input type="hidden" name="roleName" value="${status.value}"/>
					</c:if>
				</spring:bind>
			</td>
		</tr>
		<tr>
			<th>
				<StoreAdmin:label key="appRole.roleDetail"/>
			</th>
			<td>
				<spring:bind path="appRole.roleDetail">
					<textarea cols="60" rows="4" id="${status.expression}" name="${status.expression}">${status.value}</textarea>
					<span class="fieldError"><c:out value="${status.errorMessage}"/></span>
				</spring:bind>
			</td>
		</tr>
	</table>
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="com_modi_table">
		<tr>
			<td width="50%">
				<table width="100%">
					<tr>
						<th class="title"> <h4 style="padding:3px 10px">分配菜单</h4></th>
					</tr>
					<tr>
						<td>
							<ul class="tree" style="margin-left:40px;"><c:forEach items="${allMenus}" var="pms">
								<li>
									<input type="checkbox" name="ckMenuId" value="${pms.menuId}"  ${appRole.roleName eq DEFAULT_ADMIN_ROLE_NAME?'disabled="true"':''}/>
									<label title="${pms.title}<c:if test="${not empty pms.url}">(${pms.url})</c:if>">${pms.title}</label>
									<ul><c:forEach items="${pms.children}" var="sms">
										<li>
											<input type="checkbox" name="ckMenuId" value="${sms.menuId}" ${appRole.roleName eq DEFAULT_ADMIN_ROLE_NAME?'disabled="true"':''}/>
											<label title="${sms.title}<c:if test="${not empty sms.url}">(${sms.url})</c:if>">${sms.title}</label>
											<ul><c:forEach items="${sms.children}" var="rs">
												<li>
													<input type="checkbox" name="ckMenuId" value="${rs.menuId}" ${appRole.roleName eq DEFAULT_ADMIN_ROLE_NAME?'disabled="true"':''}/>
													<label title="${rs.title}<c:if test="${not empty rs.url}">(${rs.url})</c:if>">${rs.title}</label>
												</li></c:forEach>
											</ul>
										</li></c:forEach>
									</ul>
								</li></c:forEach>
							</ul>
							<c:if test="${empty allMenus}">无菜单</c:if>
						</td>
					</tr>
				</table>
			</td>
			<td width="50%">
				<table width="100%">
					<tr>
						<th class="title"> <h4 style="padding:3px 10px">分配权限</h4></th>
					</tr>
					<tr>
						<td>
							<ul class="tree" style="margin-left:40px;"><c:forEach items="${allRess}" var="pms">
								<li>
									<input type="checkbox" name="ckMenuId" value="${pms.menuId}"  ${appRole.roleName eq DEFAULT_ADMIN_ROLE_NAME?'disabled="true"':''}/>
									<label title="${pms.title}<c:if test="${not empty pms.url}">(${pms.url})</c:if>">${pms.title}</label>
									<ul><c:forEach items="${pms.children}" var="sms">
										<li>
											<input type="checkbox" name="ckMenuId" value="${sms.menuId}" ${appRole.roleName eq DEFAULT_ADMIN_ROLE_NAME?'disabled="true"':''}/>
											<label title="${sms.title}<c:if test="${not empty sms.url}">(${sms.url})</c:if>">${sms.title}</label>
											<ul><c:forEach items="${sms.children}" var="rs">
												<li>
													<input type="checkbox" name="ckMenuId" value="${rs.menuId}" ${appRole.roleName eq DEFAULT_ADMIN_ROLE_NAME?'disabled="true"':''}/>
													<label title="${rs.title}<c:if test="${not empty rs.url}">(${rs.url})</c:if>">${rs.title}</label>
												</li></c:forEach>
											</ul>
										</li></c:forEach>
									</ul>
								</li></c:forEach>
							</ul>
							<c:if test="${empty allMenus}">无权限</c:if>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	</form>
</div>
<v:javascript formName="appRole" staticJavascript="false"/>
<script type="text/javascript">

</script>